package ar.edu.unicen.pladema.ui.panel.options;

import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Composite;

import ar.edu.unicen.pladema.main.SWTUtils;
import ar.edu.unicen.pladema.ui.mywidgets.ColorListItem;
import ar.edu.unicen.pladema.ui.mywidgets.RectSize;
import ar.edu.unicen.pladema.vc1.model.GraphicAttributes;
import ar.edu.unicen.pladema.vc1.practico.PanelOption;

public class POP1E2 extends PanelOption {
	private RectSize rectSize;
	private ColorListItem inicio;
	private ColorListItem fin;
	
	public POP1E2(Composite parent, IPaintIt pi, GraphicAttributes ga) {
		super(parent, pi, ga);
	}

	@Override
	protected FormData layoutWidgets(FormData fd) {
		
		rectSize.setLayoutData(fd);
		inicio.setLayoutData(SWTUtils.createBelowFormData(rectSize));
		fin.setLayoutData(SWTUtils.createBelowFormData(inicio));
		return SWTUtils.createBelowFormData(fin,5);
	}

	@Override
	protected void loadGraphicData() {
		rectSize.setWidth(graphicAttributes.getInt(GraphicAttributes.CLIENT_WIDTH));
		rectSize.setHeight(graphicAttributes.getInt(GraphicAttributes.CLIENT_HEIGHT));
	}

	@Override
	protected void saveGraphicData() {
		graphicAttributes
			.add(GraphicAttributes.CLIENT_WIDTH, rectSize.getWidth())
			.add(GraphicAttributes.CLIENT_HEIGHT, rectSize.getHeight());
	}

	@Override
	protected void createWidgetsImpl() {
		rectSize = new RectSize(this);
		inicio = new ColorListItem(this, null);
		fin = new ColorListItem(this, null);
		inicio.setText("Iniciar con ");
		fin.setText("Finalizar con ");
		inicio.setColor(new RGB(0, 0, 0));
		fin.setColor(new RGB(255, 255, 255));
	}

	public RGB getFinColor() {
		return fin.getColor();
	}

	public RGB getInicioColor() {
		return inicio.getColor();
	}
}
